import request from '@/utils/request'

/**
 * 获取余额信息
 */
export function getBalanceInfo() {
  return request({
    url: '/api/withdrawal/balance',
    method: 'get'
  })
}

/**
 * 提交提现申请
 * @param {Object} data 提现申请数据
 * @param {number} data.amount 提现金额
 * @param {string} data.method 提现方式 bank/alipay/wechat
 * @param {string} data.account 收款账户
 * @param {string} data.accountName 账户姓名
 * @param {string} data.remark 备注
 */
export function submitWithdrawalRequest(data) {
  return request({
    url: '/api/withdrawal/apply',
    method: 'post',
    data
  })
}

/**
 * 获取提现记录列表
 * @param {Object} params 查询参数
 * @param {number} params.page 页码
 * @param {number} params.size 每页数量
 * @param {string} params.status 状态筛选
 */
export function getWithdrawalRecordsList(params) {
  return request({
    url: '/api/withdrawal/records',
    method: 'get',
    params
  })
}

/**
 * 取消提现申请
 * @param {string|number} id 提现申请ID
 */
export function cancelWithdrawalRequest(id) {
  return request({
    url: `/api/withdrawal/cancel/${id}`,
    method: 'put'
  })
}

/**
 * 获取提现详情
 * @param {string|number} id 提现申请ID
 */
export function getWithdrawalDetail(id) {
  return request({
    url: `/api/withdrawal/detail/${id}`,
    method: 'get'
  })
}

/**
 * 获取提现配置
 */
export function getWithdrawalConfig() {
  return request({
    url: '/api/withdrawal/config',
    method: 'get'
  })
}

/**
 * 获取提现统计
 * @param {Object} params 查询参数
 * @param {string} params.startDate 开始日期
 * @param {string} params.endDate 结束日期
 */
export function getWithdrawalStats(params) {
  return request({
    url: '/api/withdrawal/stats',
    method: 'get',
    params
  })
}

/**
 * 导出提现记录
 * @param {Object} params 查询参数
 */
export function exportWithdrawalRecords(params) {
  return request({
    url: '/api/withdrawal/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}
